package it.polimi.traveldream.ejbclient.dtos;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Min;

public class BaseProductDTO implements Serializable {
	private static final long serialVersionUID = 6965957411684705388L;
	private int id;
	private String description;
	private Date endTrip;
	private int maxAvailability;
	private boolean overpast;
	private BigDecimal price;
	private int reservations;
	private Date startTrip;
	
	public BaseProductDTO() {
		super();
	}

	public BaseProductDTO(int id, String description, Date endTrip,
			int maxAvailability, boolean overpast, BigDecimal price,
			int reservations, Date startTrip) {
		super();
		this.id = id;
		this.description = description;
		this.endTrip = endTrip;
		this.maxAvailability = maxAvailability;
		this.overpast = overpast;
		this.price = price;
		this.reservations = reservations;
		this.startTrip = startTrip;
	}


	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getEndTrip() {
		return endTrip;
	}

	public void setEndTrip(Date endTrip) {
		this.endTrip = endTrip;
	}

	@Min(value = 0, message = "Invalid number of availability")
	public int getMaxAvailability() {
		return maxAvailability;
	}

	public void setMaxAvailability(int maxAvailability) {
		this.maxAvailability = maxAvailability;
	}

	public boolean isOverpast() {
		return overpast;
	}

	public void setOverpast(boolean overpast) {
		this.overpast = overpast;
	}

	@DecimalMin("0")
	@Digits(fraction = 2, integer = 10, message = "Invalid price")
	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	@Min(value = 0, message = "Invalid number of reservations")
	public int getReservations() {
		return reservations;
	}

	public void setReservations(int reservations) {
		this.reservations = reservations;
	}

	public Date getStartTrip() {
		return startTrip;
	}

	public void setStartTrip(Date startTrip) {
		this.startTrip = startTrip;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BaseProductDTO other = (BaseProductDTO) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
}
